<h1>Users</h1>

<%= link_to_remote "Add New User", {:url => new_user_path, :update => "create_user" }, { :class => "create add" } %>
<br />
<div id="create_user">
</div>

<table class="index">
  <tr>
    <th>Person Name</th>
    <th>Phone</th>
    <th>Email</th>
    <th>Roles</th>
    <th>Member Since</th>
    <th>Actions</th>
  </tr>

  <% @users.each do |user| %>
    <tr>
      <td>
        <% if !user.person.is_active? %>
          <%= image_tag("/images/icons/png-8/16-circle-red-delete.png", :alt => "inactive", :title => "This user is inactive", :class => "icon") %>
        <% else %>
          <%= image_tag("/images/icons/png-8/16-circle-green-check.png", :alt => "active", :title => "This user is active", :class => "icon") %>
        <% end %>
        <%=h user.person.name %>
      </td>
      <td><%=h user.person.phone %></td>
      <td><%=h user.email %></td>
      <td>
        <% user.person.roles.each do |role| %>
          <%= image_tag("/images/icons/roles/16-#{role}.png", :alt => "#{role}", :title => "#{role}") %><%= " " unless role == user.person.roles.last %>
        <% end %>
      </td>
      <td><%=h time_ago_in_words(user.created_at) << " ago" %></td>
      <td><%= link_to image_tag("/images/icons/png-8/16-file-page.png", :alt => "Show", :title => "Show #{user.person.name}", :class => "icon"), user %> <%= link_to image_tag("/images/icons/png-8/16-em-pencil.png", :alt => "Edit", :title => "Edit #{user.person.name}", :class => "icon"), edit_user_path(user) %> <%#= link_to image_tag("/images/icons/png-8/16-em-cross.png", :alt => "Remove User", :title => "Remove #{user.person.name}", :class => "icon"), user, :confirm => "Are you sure you want to remove this user (#{user.person.name})?", :method => :delete%></td>
    </tr>
  <% end %>

</table>